clear
rng default
load PXY_cond 
load V_CS
%% Construct grid of parameters to check 
u01grid=0; %location normalisation [Ychosen=0, X=1]
u02grid=0; %location normalisation
u11grid=V_11_CS; %scale normalisation
gran=0.1;  
u12grid= -10:gran:10;  
u22grid= -10:gran:10; 
u21grid= -10:gran:10;  
% try different values of gran and different sizes of grid hypercube as discussed in Appendix C of the paper (need powerful cluster to run the code for higher values of gran and larger sizes of hypercube)
[ca, cb, cc, cd, ce, cf] = ndgrid(u01grid, u11grid, u21grid, u02grid, u12grid, u22grid);
u01grid=ca(:);
u11grid=cb(:);
u21grid=cc(:);
u02grid=cd(:);
u12grid=ce(:);
u22grid=cf(:);
%% Jobs
workers=500; %number of parallel workers
jobs=round(size(u12grid,1)/workers); %number of jobs per parallel worker